package com.simon.train.business.controller.admin;


import com.simon.train.business.dto.DailyTrainTicketQueryDto;
import com.simon.train.business.dto.DailyTrainTicketSaveDto;
import com.simon.train.business.service.DailyTrainTicketService;
import com.simon.train.business.vo.DailyTrainTicketQueryVO;
import com.simon.train.common.Result.Result;
import com.simon.train.common.vo.PageVO;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/dailyTrainTicket")
public class DailyTrainTicketAdminController {

    @Resource
    private DailyTrainTicketService dailyTrainTicketService;

    @PostMapping("/save")
    public Result<Object> SaveDailyTrainTicket(@Valid @RequestBody DailyTrainTicketSaveDto dailyTrainTicketSaveDto){
        dailyTrainTicketService.SaveDailyTrainTicket(dailyTrainTicketSaveDto);
        return new Result<>();
    }

    @GetMapping("/queryList")
    public Result<PageVO<DailyTrainTicketQueryVO>> DailyTrainTicketQueryList(@Valid DailyTrainTicketQueryDto dailyTrainTicketQueryDto){
         /**
         * businessId通过线程变量获取 从而不需要由前端传入 保证了效率和安全性
         */
        PageVO<DailyTrainTicketQueryVO> lists = dailyTrainTicketService.QueryDailyTrainTicketList(dailyTrainTicketQueryDto);
        return new Result<>(lists);
    }

    @DeleteMapping("/delete/{id}")
    public Result<Object> DeleteDailyTrainTicket(@PathVariable("id") Long id){
        dailyTrainTicketService.deleteDailyTrainTicket(id);
        return new Result<>();
    }

}
